package net.itgoo.parkingpay.rest.model;

import org.json.JSONObject;

public class ParkingOrderModel {
    public static final int ORDER_STATE_CREATE = 0;
    public static final int ORDER_STATE_PAID = 1;
    public static final int ORDER_STATE_CANCEL = 2;

    public double amount;
    public String carPark;
    public int cid;
    public long id;
    public String inPlace;
    public String inTime;
    public String orderNo;
    public String orderTime;
    public String outPlace;
    public String plate;
    public int state;
    public String userId;

    public static ParkingOrderModel parse(JSONObject jsonObject) {
        ParkingOrderModel orderModel = new ParkingOrderModel();
        if (jsonObject != null) {
            try {
                orderModel.amount = jsonObject.getDouble("amount");
                orderModel.carPark = jsonObject.getString("carpark");
                orderModel.cid = jsonObject.getInt("cid");
                orderModel.id = jsonObject.getLong("id");
                orderModel.inPlace = jsonObject.getString("inplace");
                orderModel.inTime = jsonObject.getString("intime");
                orderModel.orderNo = jsonObject.getString("orderno");
                orderModel.orderTime = jsonObject.getString("ordertime");
                orderModel.outPlace = jsonObject.getString("outplace");
                orderModel.plate = jsonObject.getString("plate");
                orderModel.state = jsonObject.getInt("state");
                orderModel.userId = jsonObject.getString("userid");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        return orderModel;
    }
}
